﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using System.Web.Script.Serialization;
using VQWEB.common;
using VQWEB.huongnghiep.BL;

namespace VQWEB.huongnghiep.handlers
{
    /// <summary>
    /// Summary description for Quiz
    /// </summary>
    public class QuizHandler : IHttpHandler, IRouteHandler
    {
        ProfessionData ProfessionData = new ProfessionData();
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        public void ProcessRequest(HttpContext context)
        {
            string type = context.Request["type"];
            if(!String.IsNullOrEmpty(type))
            {
                var json = serializer.Serialize(ProfessionData.GetQuizByType(type));
                context.Request.ContentType = "application/json";
                context.Response.Write(json);
            }
        }

        public IHttpHandler GetHttpHandler(RequestContext RequestContext)
        {
            return this;
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}